#ifndef NODE_H
#define NODE_H

#include <QObject>
#include <QVector>

#include "Distribution.h"

class Node : public QObject
{
public:
    enum NodeType {
        CONSTANT,
        NORMAL,
        BETA,
        GAMMA,
        INVERSE_GAMMA,
        BERNOULLI,
        POISSON,
        MISC
    };

    Node(double sampleValue);

    Node(NodeType type, double sampleValue = 0.0, bool isObserved = false, QString label = QString());

    Node(const Node& other);

    virtual ~Node();

    virtual double randomSample() { return 0.0; }

    double logLikelihood();

    virtual double logLikelihood(double x) { Q_UNUSED(x); return 0.0; }

    virtual NodeType type() { return nodeType; }

    void setProposalStandardDeviation(double proposalStdDev);

    QVector<Node*> children();

    void addChild(Node* node);

    virtual double getLastSample();

    virtual double sample();

    bool shouldSample();

    void setSampleHistory(QVector<double> history);

    QVector<double> getSampleHistory();

    void dropSampleHistoryUpTo(int number);

    double mean();

    double variance();

    double minimum();

    double maximum();

    QVector<int> histogram();

    QVector<QPointF> histogramLine();

    QString label();

protected:
    double lastSample;
    QVector<double> sampleHistory;
    QVector<Node*> nodeChildren;

private:
    NodeType nodeType;
    bool isObserved;
    double proposalSigma;
    QString nodeLabel;

};

#endif // NODE_H
